import re


def validate_generation_request(data):
    """验证生成字符串请求参数"""
    errors = []

    # 检查必需字段
    if 'length' not in data:
        errors.append('缺少length参数')
    elif not isinstance(data['length'], int) or data['length'] <= 0:
        errors.append('length必须是正整数')

    if 'char_type' not in data:
        errors.append('缺少char_type参数')
    elif data['char_type'] not in ['digits', 'letters', 'digits_letters', 'symbols',
                                   'digits_letters_symbols', 'chinese', 'custom']:
        errors.append('无效的char_type参数')

    # 检查自定义字符集
    if data.get('char_type') == 'custom' and not data.get('custom_chars'):
        errors.append('自定义字符类型需要提供custom_chars参数')

    # 检查前缀后缀长度
    prefix = data.get('prefix', '')
    suffix = data.get('suffix', '')

    if len(prefix) + len(suffix) > data.get('length', 0):
        errors.append('前缀和后缀的总长度不能超过字符串总长度')

    return errors